package com.songshuai.webapi.baseapi.enumerations.sales;

public enum CustomerActionEnum {
    View(1, "浏览"),
    Share(2, "分享"),
    good(3, "点赞"),
    Comment(4, "评价");


    private int code;
    private String msg;

    CustomerActionEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return CustomerActionEnum.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return CustomerActionEnum.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(CustomerActionEnum err : CustomerActionEnum.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
